NoLang Script
A NoLang Script is a JSON object of a pre defined entity with those fields which described in the entity's schema, besides some additional properties specially
A NoLang Script can be sent to a NoLang app via the app's endpoints or inline its schemas using any object value containing
$$schema
and $$header
. A NoLang Script can be sent to a NoLang app via the app's endpoints or inline its schemas using any object value containing
$$header
keyword.CRUD actions in NoLang
When we are building APIs, we want our models to provide four basic types of functionality. The model must be able to Create, Read, Update, and Delete resources. Computer scientists often refer to these functions by the acronym CRUD. A model should have the ability to perform at most these four functions in order to be complete.
How to Create a new instance of an Entity and add to it?
For adding data to an entity, a script like below must be sent to a NoLang endpoint.
{
"$$schema": "entity-schema-id",
"$$header": {
"action": "C"
},
"FieldName1": "Hello",
"FieldName2": 25
}
How to Retrieve value from an Entity?
All things are by JSON syntax. For loading data of an entity, a script like below must be sent to a NoLang endpoint.
{
"$$schema": "entity-schema-id",
"$$header": {
"action": "R"
}
}
How to Update value to an Entity?
All things are by JSON syntax. For setting data to an entity, a script like below must be sent to a NoLang server.
{
"$$schema": "entity-schema-id",
"$$header": {
"action": "U",
"filter": {
"FieldName2": 25
}
},
"FieldName1": "Bye"
}
How to Delete value from an Entity?
For deleting data from an entity, a script like below can be used.
{
"$$schema": "entity-schema-id",
"$$header": {
"action": "D",
"filter": {
"FieldName2": 25
}
}
}
How to call a Method in an Entity?
For calling a method of an entity, a script like below can be used.
{
"$$schema": "entity-with-methods",
"$$header": {
"action": "M",
"method": "wait",
"params": {
"seconds": 20
}
}
}
$$header
Using
$$header
many specifications of request can be sent to server{
"$$schema": "entity",
"$$header": {
"action": "R",
"filter": {
"field1": "value1",
"field2": {
"$gt": "value2"
}
},
"filterrules": {
"<=": [
{
"var": "field2"
},
3
]
},
"limit": 20,
"skip": 1,
"sort": {
"field1": 1,
"field2": -1
}
}
}
$$header.then
and $$header.else
Use
then
in $$header
to be run after the script. It can be nested.Use
Use
else
in $$header
to be run if the script cant be run. It can be nested. Use
$$set
object to set values of entity properties{
"$$schema": "entity1",
"$$header": {
"action": "C",
"then": {
"$$set": {
"propY": "{{entity1.propX}}"
}
},
"else": {
"$$schema": "messages",
"$$header": {
"action": "C"
},
"message": "new Entity1 cant be created by field {{entity1.propX}}"
}
},
"propX": "value1"
}